package com.example.common.dialog

import android.content.Context
import android.content.DialogInterface
import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.os.Bundle
import android.view.WindowManager
import android.widget.ImageView
import androidx.appcompat.app.AppCompatDialog
import com.example.common.R

class AppUpdateDialog : AppCompatDialog {

    constructor(context: Context):super(context){

    }
    constructor(context: Context,theme : Int):super(context,theme){

    }
    constructor(context: Context,cancelable: Boolean,cancelListener:DialogInterface.OnCancelListener ):super(context,cancelable,cancelListener){

    }
  private  var cancel : ImageView ? = null
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.updata_layout)
        //取消按钮点击事件
        cancel = findViewById(R.id.iv_cancel)
        cancel!!.setOnClickListener {
            cancel()
        }

        //获取布局参数
        var windowparms : WindowManager.LayoutParams? =window?.attributes
        windowparms?.apply {
            dimAmount =0.4f//灰色区域暗度
            width = WindowManager.LayoutParams.MATCH_PARENT
            height = WindowManager.LayoutParams.MATCH_PARENT
        }
        //重新复制
        window?.attributes=windowparms
        //设置透明度
        window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))

        //设置可取消
        setCanceledOnTouchOutside(true)
        setCancelable(true)
    }



}